package com.sky.Screen;

import java.util.ArrayList;

import com.healthcare.widget.ActionBar;
import com.healthcare.widget.ActionBar.IntentAction;
import com.sky.Model.Item;
import com.sky.Model.LocationItem;
import com.sky.Model.SubjectItem;
import com.sky.Model.serviceItem;
import com.sky.adapter.CustomGridViewAdapter;
import com.sky.adapter.ServicesAdapter;
import com.sky.adapter.SubjectAdapter;
import com.sky.adapter.listLocationAdapter;
import com.sky.heathcare.HealthCareApp;
import com.sky.heathcare.R;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ListView;

public class ListSubjectActivity extends Activity {

	ListView lstView;
	ArrayList<SubjectItem> listArray = new ArrayList<SubjectItem>();
	SubjectAdapter listAdapter;

	int nTabPos = 0;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.lst_subj_activity);
		
		if (savedInstanceState == null) {
            Bundle extras = getIntent().getExtras();
            if(extras == null) {
            	nTabPos = 0;
            } else {
            	nTabPos= extras.getInt("TAB_POS");
            }
        } 
		
		initData();

		lstView = (ListView) findViewById(R.id.listSubject);
		listAdapter = new SubjectAdapter(this, R.layout.subject_item,listArray);
				
		
		lstView.setAdapter(listAdapter);
		listAdapter.notifyDataSetChanged();
		
		lstView.setOnItemClickListener(new OnItemClickListener() {

		    public void onItemClick(AdapterView<?> parent, View view, int position,long arg3) {
		        view.setSelected(true);
		        
		        SubjectItem item = listArray.get(position);
		        if(item != null)
		        {
		        	//goto database to get data
		        }
		    }
		});


	}

	private void initData() {		

		HealthCareApp app = (HealthCareApp)getApplicationContext();
		if(app != null)
		{
			nTabPos = KnowlegeActivity.tabHost.getCurrentTab();
			switch (nTabPos) {
			case 0:
				listArray.add(new SubjectItem( "Cac loai thuc an nen tranh:", "120,000"));
				listArray.add(new SubjectItem( "Dua gai voi ba bau", "90,000"));
				listArray.add(new SubjectItem( "Mua lanh mac gi", "150,000"));
				listArray.add(new SubjectItem( "Cac phong tranh lanh", "70,000"));
				listArray.add(new SubjectItem( "Kieng nuoc nhu the nao", "100,000"));
				listArray.add(new SubjectItem( "Cac loai hai san nen tranh", "60,000"));
				
				listArray.add(new SubjectItem( "Luu y khi an lau", "50,000"));
				listArray.add(new SubjectItem( "Co nen an rau song", "50,000"));
				listArray.add(new SubjectItem( "Uong nuoc co ga", "50,000"));
				listArray.add(new SubjectItem( "Co nen uong bia", "50,000"));
				listArray.add(new SubjectItem( "Co nen uong ruou", "50,000"));
				listArray.add(new SubjectItem( "Some thing like that", "50,000"));
				break;
			case 1:
				listArray.add(new SubjectItem( "Dung rau cu qua lam thuoc", "120,000"));
				listArray.add(new SubjectItem( "Cong dung cua gung", "90,000"));
				listArray.add(new SubjectItem( "Chao tia to", "150,000"));
				listArray.add(new SubjectItem( "Tranh cam han", "70,000"));
				listArray.add(new SubjectItem( "tac dung cua toi kho", "100,000"));
				listArray.add(new SubjectItem( "Cham soc da khi phu ne", "60,000"));
				
				listArray.add(new SubjectItem( "Mo so kinh nghiem dan gian hay", "50,000"));
				listArray.add(new SubjectItem( "Tac dung cua rau ngo", "50,000"));			
				break;
			case 2:
				listArray.add(new SubjectItem( "Khong nen di giay cao", "120,000"));
				listArray.add(new SubjectItem( "Tranh van dong nhanh", "90,000"));
				listArray.add(new SubjectItem( "Khong nen tu dieu khien xe may", "150,000"));
				listArray.add(new SubjectItem( "Tranh cho xoc", "70,000"));
				listArray.add(new SubjectItem( "di toc do nao la hop ly", "100,000"));
				listArray.add(new SubjectItem( "ngoi the nao dung cach", "60,000"));
			
				break;
			default:
				break;
			}
		}
		

	}
}
